<!-- YouTubeBuscar -->

<%@ page import="eudjok.Musica" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'musica.label', default: 'Musica')}" />
        <title><g:message code="default.buscar.label" args="[entityName]" /></title>
    </head>
    <body>
	
        <div id="navegacao">
           	 	<div class="homePagePanel">
           	     	<div class="panelTop"></div>
           	     	<div class="panelBody" id="panelBody">
           	        	 <g:render template="/common/perfil/Dj" />
           	     	</div>
           	    	 <div class="panelBtm"></div>
           		 </div>
        	</div>
			
				
			<div id="centroLivre">
				<h2 class="pretoPrincipal">Adicionar Música</h2>
				<g:if test="${flash.message}">
				<div class="message">${flash.message}</div>
				</g:if>
				<g:hasErrors bean="${musicaInstance}">
				<div class="errors">
					<g:renderErrors bean="${musicaInstance}" as="list" />
				</div>
				</g:hasErrors>
							
				<g:form action="buscar" >
					<div class="dialog">
						
						<table>
							<tbody>
							
								<tr class="prop">
									<td valign="top" class="name">
										<label for="titulo"><g:message code="musica.titulo.label" default="Adicionar músicas" /></label>
									</td>
									<td valign="top" class="value ${hasErrors(bean: params, field: 'key', 'errors')}">
										<g:textField name="key" value="${params?.key}" />
									</td>
								</tr>
							
							</tbody>
						</table>
					</div>
					
					<div class="buttons">
						<span class="button"><g:submitButton name="buscar" class="edit" value="${message(code: 'default.button.buscar.label', default: 'Buscar')}" /></span>
					</div>
				</g:form>
				
				<br/>
				
				<g:if test="${!videos}">
					<br/>
					<a href="${flash.pagina}">Ops!! Nenhum video foi carregado! Faça uma nova busca!</a>
				</g:if>
				
					<div>
						<table>
							<tbody>
							<g:each in="${videos}" status="i" var="video">
								
								<g:if test="${(i%4) == 0}">
									<tr>
								</g:if>
									<td colspan="1"><div style="overflow: hidden; width: 183; height: 14px;" >
										${fieldValue(bean: video, field: "title")}</div><br/>
										<g:link controller="musica" action="saveYoutube" params="[titulo:video.title, descricao:video.description, url:video.videoId, usuarioExterno:video.user]">
										<img class="imagemMusica" src="${video.getThumbnails()[0]}"	width="183" height="123" /></g:link>
									</td>
								<g:if test="${(i%4) == 3}">
									</tr>
								</g:if>
								
								
							</g:each>
								
							
							</tbody>
						</table>
					</div>
				
			</div>
        </div>
    </body>
</html>